package com.bicon.botu.medical.api

import com.baomidou.mybatisplus.plugins.Page
import com.bicon.botu.core.base.common.controller.BaseController
import com.bicon.botu.core.base.common.entity.BaseResult
import com.bicon.botu.medical.model.entity.FitnessTrain
import com.bicon.botu.medical.service.FitnessActionService
import com.bicon.botu.medical.service.FitnessTrainService
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiImplicitParams
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/api/fitness")
open class FitnessApi : BaseController() {

    @Autowired
    open lateinit var trainService: FitnessTrainService

    @Autowired
    open lateinit var actionService: FitnessActionService

    @ApiOperation(value = "分页查询训练", notes = "分页查询训练")
    @ApiImplicitParams(
            ApiImplicitParam(name = "pageSize", value = "页大小", required = true, dataType = "Int", paramType = "query"),
            ApiImplicitParam(name = "currentPage", value = "当前页", required = true, dataType = "Int", paramType = "query")
    )
    @GetMapping("/train/list")
    fun getListTrain(@RequestParam pageSize: Int,
                     @RequestParam currentPage: Int ): BaseResult<*> {

        var page = Page<FitnessTrain>(currentPage, pageSize)
        return sendResult200(trainService.selectPage(page))
    }
}